<template>
	<div>
		<el-breadcrumb separator-class="el-icon-arrow-right">
		  	<el-breadcrumb-item :to="{ path: '/base' }">首页</el-breadcrumb-item>
		  	<el-breadcrumb-item>基础信息配置</el-breadcrumb-item>
		</el-breadcrumb>
		
			
		
		
		<el-form ref="form" :model="form" label-width="115px" style="width:100%;">
		 <el-row class="good_detail">
			 <div class="canEdit">
				 
				 <el-form-item label="图表价格区间" class="item-detail">
				   <el-input v-model="goods.FSalePrice"  placeholder="价格区间"></el-input>
				 </el-form-item>
				 <el-form-item label="款式价格百分比" class="item-detail" style="clear: left;">
				   <el-input v-model="goods.price"  placeholder="价格波动百分比(%) 填写范围(0-1)"></el-input>
				 </el-form-item>
				 
			 </div>
			  
		  </el-row>
		  
		  <el-form-item class="submit">
		    <el-button type="primary" @click="onSubmit">提交</el-button>
		    <el-button>取消</el-button>
		  </el-form-item>
		</el-form>	

		  
	</div>
</template>

<script type="text/javascript">
	import E from 'wangeditor'
	import 'wangeditor/release/wangEditor.min.css'
	export default{
		data(){
			return{
				cateList:[],
				goods:{
					FSalePrice:'',
					price:''
				},
				form: {
				      FSalePrice: '',
				    },
			}
		},
		mounted () {
	      	/*this.phoneEditor = new E('#websiteEditorElem')
	      	this.phoneEditor.onchange = function () {
	        	this.goods.detailText = this.$txt.html()
	      	}
	      	this.phoneEditor.create()
	      	*/
		   
	    },
		created(){
			//this.goods._token = window.axios.defaults.headers.common['X-CSRF-TOKEN'];
			//this.getCates();
			this.getGood();
			
		},
		methods:{
		
			 onSubmit() {
			        // console.log('submit!',this.goods);
					// let pragam =  this.goods;
					// axios.get('/api/style/edit?style='+ pragam)
					let price = this.goods.price;
					let a = price -1;
					if(-1 <= a && a <= 0){
						axios.post('/api/base/editconfig', {
								FSalePrice  : this.goods.FSalePrice,
								price:this.goods.price
							  })
							  .then(res => {
								if(res.data.code ==200){
									this.$notify({
									  title: '成功',
									  message: res.data.message,
									  type: 'success'
									});
								}
							  	
							  })
							  .catch(error => {
								  this.$notify.error({
								    title: '错误',
								    message: error.data.message,
								  });
							  })
					}else{
						this.$message.error('价格波动百分比范围数据类型必须为（0-1）');
					}
					
			      },
				  getGood(){
				  	axios.get('/api/base/detailconfig')
				  		.then(res => {
				  			var data = res.data.result; 
				  			this.goods.FSalePrice = data.FSalePrice;
							this.goods.price = data.price;
				  			console.log(data);
				  		})
				  		.catch(error => {
				  			console.log(111);
				  		})
				  },
			
		}
	}
</script>

<style lang="scss" >
	input[type=file] {
	    display: none;
	}
	.submit{
		margin-top: 30px;
	}
	.good_detail{
		.canEdit{
			float: left;
			width: 100%;
			margin-top: 25px;
			.el-input__inner{
				width: 400px;
			}	
			.item-detail{
				float: left
			}
		}
	}
</style>